package Operation;

import Personnel.Student;
import Class.ClassMate;

import java.util.Scanner;

public class FindOperation implements Ioperation {

    @Override
    public void work(ClassMate classmate) {
        System.out.println("查找学生");
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入要找的学生姓名");
        String name = scanner.nextLine();

        int currentSize = classmate.getClassSize();
        for (int i = 0; i < currentSize; i++) {
            Student student = classmate.getStudent(i);
            if(student.getName().equals(name)){
                System.out.println("找到了！！");
                System.out.println(student.toString());
                return;
            }
        }
        System.out.println("找不到");
    }
}
